#include <iostream>

using namespace std;

const int N = 1e5 + 10;

typedef long long LL;

//一段路的费用：A 或 B+C
//一段路经过k次，至少花 min(A*k, B*k+C)
//一段路经过多少次-->某一段区间同时加上1

int n, m;
LL f[N]; // 差分数组

int main()
{
	cin >> n >> m;

	//统计
	int x; cin >> x;
	for(int i = 2; i <= m; i++)
	{
		int y; cin >> y;
		if(x > y) 
		{
			f[y]++; 
			f[x]--;
		}
		else 
		{
			f[x]++;
			f[y]--;
		}
		x = y;
	}

	//还原差分数组
	for(int i = 1; i <= n; i++) f[i] += f[i - 1];

	//直接求结果
	LL sum = 0;
	for(int i = 1; i < n; i++)
	{
		LL a, b, c; cin >> a >> b >> c;
		sum += min(a * f[i], b * f[i] + c);
	}
	cout << sum << endl;
	

	return 0;
}
